# 抽象产品类
class AbstractProduct:
    def operation(self):
        pass

# 具体产品类1
class ConcreteProduct1(AbstractProduct):
    def operation(self):
        print("ConcreteProduct1 operation")

# 具体产品类2
class ConcreteProduct2(AbstractProduct):
    def operation(self):
        print("ConcreteProduct2 operation")

# 抽象工厂类
class AbstractFactory:
    def create_product(self):
        pass

# 具体工厂类1，继承自抽象工厂类
class ConcreteFactory1(AbstractFactory):
    def create_product(self):
        return ConcreteProduct1()

# 具体工厂类2，继承自抽象工厂类
class ConcreteFactory2(AbstractFactory):
    def create_product(self):
        return ConcreteProduct2()

# 客户端代码
class Client:
    def __init__(self, factory: AbstractFactory):
        self.factory = factory

    def get_product(self):
        product = self.factory.create_product()
        product.operation()

# 使用示例
if __name__ == "__main__":
    # 客户端选择具体工厂1来创建产品
    factory1 = ConcreteFactory1()
    client1 = Client(factory1)
    client1.get_product()  # 输出: ConcreteProduct1 operation

    # 客户端选择具体工厂2来创建产品
    factory2 = ConcreteFactory2()
    client2 = Client(factory2)
    client2.get_product()  # 输出: ConcreteProduct2 operation

'''
代码实现：
ConcreteProduct1 operation
ConcreteProduct2 operation
'''